<template>
  <div>
    <h1>我的页面2</h1>

    <ul>
      <li><router-link to="/myhome1/neirong">1</router-link></li>
      <li><router-link to="/myhome1/neirong1">2</router-link></li>
      <li><router-link to="/myhome1/neirong2">3</router-link></li>
    </ul>
    <button @click="btn">点击随机</button>

    <div>
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: ["/myhome1/neirong", "/myhome1/neirong1", "/myhome1/neirong2"],
    };
  },
  methods: {
    btn() {
      let a = this.arr[Math.floor(Math.random() * this.arr.length)];
      if (this.$route.path !== a) {
        this.$router.replace(a);
      }
    },
  },
};
</script>

<style>
</style>